package factory;

import agricultural.AgriculturalMachine;
import agricultural.Harvester;
import agricultural.Planter;
import agricultural.Sprayer;
import agricultural.Tractor;

public interface AgriculturalMachineFactory {

    AgriculturalMachine createMachine(String machineId);

    public static AgriculturalMachine createMachine(MachineType type, String machineId) {
        switch (type) {
            case TRACTOR:
                return new Tractor(machineId);
            case PLANTER:
                return new Planter(machineId);
            case HARVESTER:
                return new Harvester(machineId);
            case SPRAYER:
                return new Sprayer(machineId);
            default:
                throw new IllegalArgumentException("不支持的农机类型: " + type);
        }
    }

}